<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/dute_favicon_32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/dute_favicon_16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">
  <link rel="manifest" href="/images/manifest.json">
  <meta name="msapplication-config" content="/images/browserconfig.xml">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">
  <meta name="google-site-verification" content="mpI5dkydstZXl6UcDCppqktXK0bbvqdZ6LkZ3KNk4Iw">
  <meta name="baidu-site-verification" content="code-a1LksZX2Ds">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"whitestore.top","root":"/","scheme":"Gemini","version":"7.8.0","exturl":true,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":true,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="使用maven搭建私服">
<meta property="og:type" content="article">
<meta property="og:title" content="【Maven】Maven私服Nexus搭建教程">
<meta property="og:url" content="https://whitestore.top/2020/07/26/mavennexus/index.html">
<meta property="og:site_name" content="爱看书的阿东">
<meta property="og:description" content="使用maven搭建私服">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/jiuhe/20200318141611.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/jiuhe/20200327201355.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/jiuhe/20200327201558.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200328234944.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200328235057.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170837.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329002328.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329164131.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329165902.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170010.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170040.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170809.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170521.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329171028.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405114219.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405114639.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115034.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115136.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115216.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115356.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115744.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405142135.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405162751.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405162923.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405164619.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405164857.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405170455.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405170339.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405201713.png?ynotemdtimestamp=1595729096959">
<meta property="og:image" content="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405202232.png?ynotemdtimestamp=1595729096959">
<meta property="article:published_time" content="2020-07-26T03:16:10.000Z">
<meta property="article:modified_time" content="2023-07-16T06:28:09.252Z">
<meta property="article:author" content="阿东">
<meta property="article:tag" content="Maven">
<meta property="article:tag" content="Java">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/jiuhe/20200318141611.png?ynotemdtimestamp=1595729096959">

<link rel="canonical" href="https://whitestore.top/2020/07/26/mavennexus/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>【Maven】Maven私服Nexus搭建教程 | 爱看书的阿东</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="爱看书的阿东" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">爱看书的阿东</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">赐他一块白色石头，石头上写着新名</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
        <li class="menu-item menu-item-sitemap">

    <a href="/sitemap.xml" rel="section"><i class="fa fa-fw fa-sitemap"></i>站点地图</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    

  <span class="exturl github-corner" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="Follow me on GitHub" aria-label="Follow me on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></span>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://whitestore.top/2020/07/26/mavennexus/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="阿东">
      <meta itemprop="description" content="随遇而安">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="爱看书的阿东">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          【Maven】Maven私服Nexus搭建教程
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-07-26 11:16:10" itemprop="dateCreated datePublished" datetime="2020-07-26T11:16:10+08:00">2020-07-26</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-07-16 14:28:09" itemprop="dateModified" datetime="2023-07-16T14:28:09+08:00">2023-07-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Maven/" itemprop="url" rel="index"><span itemprop="name">Maven</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2020/07/26/mavennexus/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2020/07/26/mavennexus/" itemprop="commentCount"></span>
    </a>
  </span>
  
  <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>8 分钟</span>
            </span>
            <div class="post-description">使用maven搭建私服</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Nexus-私服搭建基本流程"><a href="#Nexus-私服搭建基本流程" class="headerlink" title="Nexus 私服搭建基本流程"></a>Nexus 私服搭建基本流程</h1><h2 id="Nexus-是什么？"><a href="#Nexus-是什么？" class="headerlink" title="Nexus 是什么？"></a>Nexus 是什么？</h2><p>用于实现Maven构建私人仓库的一个工具。</p>
<p>可以使用nexus 统一管理我们到依赖，不再需要再从中央仓库下载对应的jar包</p>
<a id="more"></a>

<h2 id="什么是Nexus-私服？"><a href="#什么是Nexus-私服？" class="headerlink" title="什么是Nexus 私服？"></a>什么是Nexus 私服？</h2><p>私服是在局域网的一种特殊的远程仓库，目的是代理远程仓库及部署第三方构件。有了私服之后，当 Maven 需要下载jar包时，先请求私服，私服上如果存在则下载到本地仓库。否则，私服直接请求外部的远程仓库，将jar包下载到私服，再提供给本地仓库下载。</p>
<h2 id="maven的依赖管理"><a href="#maven的依赖管理" class="headerlink" title="maven的依赖管理"></a>maven的依赖管理</h2><p><strong>简介：依赖是maven最为用户熟知的特性之一，单个项目的依赖管理并不难，但是要管理几个或者几十个模块的时，那这个依赖应该怎么管理</strong></p>
<ul>
<li><p>依赖的传递性</p>
<ul>
<li>传递性依赖是在maven2中添加的新特征，这个特征的作用就是你不需要考虑你依赖的库文件所需要依赖的库文件，能够将依赖模块的依赖自动的引入。</li>
</ul>
</li>
<li><p>依赖的作用范围</p>
<ul>
<li><p>compile</p>
<ul>
<li>这是默认范围，编译依赖对项目所有的classpath都可用。此外，编译依赖会传递到依赖的项目</li>
</ul>
</li>
<li><p>provided</p>
<ul>
<li>表示该依赖项将由JDK或者运行容器在运行时提供，也就是说由Maven提供的该依赖项我们只有在编译和测试时才会用到，而在运行时将由JDK或者运行容器提供。</li>
</ul>
</li>
<li><p>runtime</p>
<ul>
<li>表明编译时不需要依赖，而只在运行时依赖</li>
</ul>
</li>
<li><p>test</p>
<ul>
<li>只在编译测试代码和运行测试的时候需要，应用的正常运行不需要此类依赖。</li>
</ul>
</li>
<li><p>system</p>
<ul>
<li><p>系统范围与provided类似，不过你必须显式指定一个本地系统路径的JAR，此类依赖应该一直有效，Maven也不会去仓库中寻找它。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">&lt;project&gt;  </span><br><span class="line">  ...  </span><br><span class="line">  &lt;dependencies&gt;  </span><br><span class="line">    &lt;dependency&gt;  </span><br><span class="line">      &lt;groupId&gt;sun.jdk&lt;&#x2F;groupId&gt;  </span><br><span class="line">      &lt;artifactId&gt;tools&lt;&#x2F;artifactId&gt;  </span><br><span class="line">      &lt;version&gt;1.5.0&lt;&#x2F;version&gt;  </span><br><span class="line">      &lt;scope&gt;system&lt;&#x2F;scope&gt;  </span><br><span class="line">      &lt;systemPath&gt;$&#123;java.home&#125;&#x2F;..&#x2F;lib&#x2F;tools.jar&lt;&#x2F;systemPath&gt;  </span><br><span class="line">    &lt;&#x2F;dependency&gt;  </span><br><span class="line">  &lt;&#x2F;dependencies&gt;  </span><br><span class="line">  ...  </span><br><span class="line">&lt;&#x2F;project&gt;</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ul>
</li>
<li><p>import</p>
<ul>
<li>范围只适用于<dependencyManagement>部分。表明指定的POM必须使用<dependencyManagement>部分的依赖。因为依赖已经被替换，所以使用import范围的依赖并不影响依赖传递。</li>
</ul>
</li>
<li><p>依赖的两大原则</p>
<ul>
<li><p>路径近者优先</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">A &gt; B &gt; C-1.0</span><br><span class="line">A &gt; C-2.0</span><br></pre></td></tr></table></figure>
</li>
<li><p>第一声明优先</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">A &gt; B &gt; D-1.0</span><br><span class="line">A &gt; C &gt; D-2.0</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
<li><p>依赖的管理</p>
<ul>
<li>依赖排除<ul>
<li>任何可传递的依赖都可以通过 “exclusion” 元素被排除在外。举例说明，A 依赖 B， B 依赖 C，因此 A 可以标记 C 为 “被排除的”</li>
</ul>
</li>
<li>依赖可选<ul>
<li>任何可传递的依赖可以被标记为可选的，通过使用 “optional” 元素。例如：A 依赖 B， B 依赖 C。因此，B 可以标记 C 为可选的， 这样 A 就可以不再使用 C。</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="如何解决jar包冲突"><a href="#如何解决jar包冲突" class="headerlink" title="如何解决jar包冲突"></a>如何解决jar包冲突</h2><p><strong>简介：当出现jar包冲突时，我们应该如何快速定位和处理jar包冲突问题</strong></p>
<ul>
<li>命令: <code>mvn dependency:tree -Dverbose</code></li>
</ul>
<h2 id="Nexus私服的秘密花园"><a href="#Nexus私服的秘密花园" class="headerlink" title="Nexus私服的秘密花园"></a>Nexus私服的秘密花园</h2><p>简介：介绍nexus服务器预置的仓库</p>
<ul>
<li>类型介绍<ul>
<li>hosted：是本地仓库，用户可以把自己的一些jar包，发布到hosted中，比如公司的第二方库</li>
<li>proxy，代理仓库，它们被用来代理远程的公共仓库，如maven中央仓库。不允许用户自己上传jar包，只能从中央仓库下载</li>
<li>group，仓库组，用来合并多个hosted/proxy仓库，当你的项目希望在多个repository使用资源时就不需要多次引用了，只需要引用一个group即可</li>
<li>virtual，虚拟仓库基本废弃了。</li>
</ul>
</li>
<li>预置仓库<ul>
<li>Central：该仓库代理Maven中央仓库，其策略为Release，因此只会下载和缓存中央仓库中的发布版本构件。</li>
<li>Releases：这是一个策略为Release的宿主类型仓库，用来部署正式发布版本构件</li>
<li>Snapshots：这是一个策略为Snapshot的宿主类型仓库，用来部署开发版本构件。</li>
<li>3rd party：这是一个策略为Release的宿主类型仓库，用来部署无法从maven中央仓库获得的第三方发布版本构件，比如IBM或者oracle的一些jar包（比如classe12.jar），由于受到商业版权的限制，不允许在中央仓库出现，如果想让这些包在私服上进行管理，就需要第三方的仓库。</li>
<li>Public Repositories：一个组合仓库</li>
</ul>
</li>
</ul>
<h2 id="Nexus-下载地址"><a href="#Nexus-下载地址" class="headerlink" title="Nexus 下载地址"></a>Nexus 下载地址</h2><p><span class="exturl" data-url="aHR0cHM6Ly93d3cuc29uYXR5cGUuY29tL25leHVzLXJlcG9zaXRvcnktb3Nz" title="https://www.sonatype.com/nexus-repository-oss">Nexus 官方网站<i class="fa fa-external-link"></i></span></p>
<p><img src="https://raw.githubusercontent.com/lazyTimes/imageRepository/master/jiuhe/20200318141611.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<h2 id="快速入门"><a href="#快速入门" class="headerlink" title="快速入门"></a>快速入门</h2><h3 id="搭建Maven-Nexus"><a href="#搭建Maven-Nexus" class="headerlink" title="搭建Maven Nexus"></a>搭建Maven Nexus</h3><ol>
<li>进入 <span class="exturl" data-url="aHR0cHM6Ly93d3cuc29uYXR5cGUuY29tL25leHVzLXJlcG9zaXRvcnktb3Nz" title="https://www.sonatype.com/nexus-repository-oss">Nexus 官方网站<i class="fa fa-external-link"></i></span></li>
<li>在首页选择 <code>“GET PREPOSITORY OSS”</code></li>
<li>页面拉倒最下面，点击<code>OSS2</code></li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/jiuhe/20200327201355.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>由于Maven Nexus 是收费的，这里我们需要使用免费的版本</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/jiuhe/20200327201558.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>下载之后，会得到如下内容</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200328234944.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>此时调出 <code>cmd</code>, 进入目录<code>D:\java\Nexus\nexus-latest-bundle\nexus-2.14.15-01\bin</code></li>
<li>运行 <code>nexus.bat start</code>，可以发现会<code>拒绝访问</code></li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200328235057.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>使用管理员模式运行<ul>
<li>运行 <code>nexus.bat install</code> 安装</li>
<li><code>nexus.bat start</code> 启动服务</li>
</ul>
</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170837.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>访问 <span class="exturl" data-url="aHR0cDovL2xvY2FsaG9zdDo4MDgxL25leHVz6L+b5YWl5YiwbmV4dXM=" title="http://localhost:8081/nexus进入到nexus">http://localhost:8081/nexus进入到nexus<i class="fa fa-external-link"></i></span> 页面</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329002328.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>进入主页</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329164131.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<h3 id="建立第一个个人仓库"><a href="#建立第一个个人仓库" class="headerlink" title="建立第一个个人仓库"></a>建立第一个个人仓库</h3><ol>
<li>完成上一节内容之后，进入主页面，点击右上角<code>Log In</code> 登陆系统</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329165902.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>Nexus 默认到用户名称和密码为 <code>admin</code> 以及 <code>admin123</code>，输入账户名和密码之后登陆系统</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170010.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>登陆之后会发现界面发生了改变，因为此时我们拥有了对应到权限</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170040.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>点击 <code>add</code>，选择 <code>Hosted Repository</code> 改含义会在后面进行解释</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170809.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>如图所示，基本上只需要填写很少到内容，就可以完成一个仓库到创建，点击下方到<code>save</code>按钮即可创建一个仓库</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329170521.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>查看配置,可以看到改仓库被放到了一个默认的地址里面</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200329171028.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<h3 id="将Jar包项目加入到个人仓库"><a href="#将Jar包项目加入到个人仓库" class="headerlink" title="将Jar包项目加入到个人仓库"></a>将Jar包项目加入到个人仓库</h3><p>这里以一个自己的项目作为测试</p>
<p>Maven依赖如下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.smart4j&lt;&#x2F;groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;smart-framwork&lt;&#x2F;artifactId&gt;</span><br><span class="line">    &lt;version&gt;1.0.0&lt;&#x2F;version&gt;</span><br><span class="line">&lt;&#x2F;dependency&gt;</span><br></pre></td></tr></table></figure>

<p>我们需要先登录Maven Nexus，具备管理员的权限，然后点击<code>3rd party</code>(三方依赖)，截图内容如下</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405114219.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<p>依照截图填入如下的依赖</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405114639.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<blockquote>
<p>GAV Definition: 定义GAV</p>
<p>Auto Guess：自动猜测</p>
<p>Group：同Maven 到 group定义</p>
<p>Artifact：同Maven 到 Artifact定义</p>
<p>Version：版本号</p>
<p>Packaging：打包方式</p>
<p>下方需要上传依赖对应到jar包</p>
</blockquote>
<p>上传之后需要添加到maven Nexus</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115034.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115136.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<p>等待上传，上传成功之后会给予对应到提示信息</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115216.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<p>上传完成之后，我们可以点击<code>Browse Index</code>看到自己之前上传的依赖</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115356.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<blockquote>
<p>默认情况下我们到公共访问地址如下：</p>
<p><span class="exturl" data-url="aHR0cDovL2xvY2FsaG9zdDo4MDgxL25leHVzL2NvbnRlbnQvZ3JvdXBzL3B1YmxpYw==" title="http://localhost:8081/nexus/content/groups/public">http://localhost:8081/nexus/content/groups/public<i class="fa fa-external-link"></i></span> 公共仓库的访问地址</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405115744.png?ynotemdtimestamp=1595729096959" alt="img"></p>
</blockquote>
<h3 id="将个人仓库的jar包添加到项目当中"><a href="#将个人仓库的jar包添加到项目当中" class="headerlink" title="将个人仓库的jar包添加到项目当中"></a>将个人仓库的jar包添加到项目当中</h3><p>把jar包添加到nexus之后，我们可以尝试让nexus来管理我们到项目依赖了</p>
<p>接下来介绍如何使用maven nexus 来关联我们到依赖</p>
<ol>
<li>我们需要建立一个存在pom文件的项目，把对应到pom依赖引入</li>
</ol>
<blockquote>
<p>注意：事先查看nexus公有仓库是否存在依赖</p>
</blockquote>
<ol>
<li>在Maven 的 <code>conf</code> 下面增加配置，以个人为例进入<code>D:\java\apach\apache-maven-3.6.0\conf</code>，修改<code>setting.xml</code>,添加如下内容</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- 添加 nexus 访问权限 --&gt;</span><br><span class="line">&lt;servers&gt;	</span><br><span class="line">	&lt;server&gt;</span><br><span class="line">	  &lt;id&gt;xdclass&lt;&#x2F;id&gt;</span><br><span class="line">	  &lt;username&gt;admin&lt;&#x2F;username&gt;</span><br><span class="line">	  &lt;password&gt;admin123&lt;&#x2F;password&gt;	</span><br><span class="line">	&lt;&#x2F;server&gt;</span><br><span class="line"></span><br><span class="line">  &lt;&#x2F;servers&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">&lt;mirrors&gt;</span><br><span class="line">	&lt;!-- 自定义 nexus --&gt;</span><br><span class="line">	 &lt;mirror&gt;</span><br><span class="line">        &lt;id&gt;xdclass&lt;&#x2F;id&gt;</span><br><span class="line">        &lt;mirrorOf&gt;nexus,central&lt;&#x2F;mirrorOf&gt;</span><br><span class="line">        &lt;url&gt;http:&#x2F;&#x2F;localhost:8081&#x2F;nexus&#x2F;content&#x2F;groups&#x2F;public&#x2F;&lt;&#x2F;url&gt;</span><br><span class="line">		&lt;name&gt;local nexus&lt;&#x2F;name&gt;  </span><br><span class="line">    &lt;&#x2F;mirror&gt;</span><br><span class="line">	&lt;!-- 阿里云配置 --&gt;</span><br><span class="line">	&lt;mirror&gt;  </span><br><span class="line">      &lt;id&gt;alimaven&lt;&#x2F;id&gt;  </span><br><span class="line">      &lt;name&gt;aliyun maven&lt;&#x2F;name&gt;  </span><br><span class="line">      &lt;url&gt;http:&#x2F;&#x2F;maven.aliyun.com&#x2F;nexus&#x2F;content&#x2F;groups&#x2F;public&#x2F;&lt;&#x2F;url&gt;  </span><br><span class="line">      &lt;mirrorOf&gt;central&lt;&#x2F;mirrorOf&gt;          </span><br><span class="line">	&lt;&#x2F;mirror&gt;  </span><br><span class="line">	</span><br><span class="line">&lt;&#x2F;mirrors&gt;</span><br><span class="line">&lt;profiles&gt;</span><br><span class="line">	&lt;profile&gt;</span><br><span class="line">        &lt;id&gt;xd&lt;&#x2F;id&gt;</span><br><span class="line">        &lt;repositories&gt;</span><br><span class="line">            &lt;repository&gt;</span><br><span class="line">                &lt;id&gt;local-nexus&lt;&#x2F;id&gt;</span><br><span class="line">                &lt;!-- 本地仓库路径 --&gt;</span><br><span class="line">                &lt;url&gt;http:&#x2F;&#x2F;localhost:8081&#x2F;nexus&#x2F;content&#x2F;groups&#x2F;public&#x2F;&lt;&#x2F;url&gt;</span><br><span class="line">                &lt;releases&gt;</span><br><span class="line">                    &lt;enabled&gt;true&lt;&#x2F;enabled&gt;</span><br><span class="line">                &lt;&#x2F;releases&gt;</span><br><span class="line">                &lt;!-- 开启快照 --&gt;</span><br><span class="line">                &lt;snapshots&gt;</span><br><span class="line">                    &lt;enabled&gt;false&lt;&#x2F;enabled&gt;</span><br><span class="line">                &lt;&#x2F;snapshots&gt;</span><br><span class="line">            &lt;&#x2F;repository&gt;</span><br><span class="line">        &lt;&#x2F;repositories&gt;</span><br><span class="line">    &lt;&#x2F;profile&gt;</span><br><span class="line">&lt;&#x2F;profiles&gt;</span><br><span class="line"></span><br><span class="line">&lt;!-- 需要 开启 Profile 配置 --&gt;</span><br><span class="line">&lt;activeProfiles&gt;</span><br><span class="line">    &lt;activeProfile&gt;xd&lt;&#x2F;activeProfile&gt;</span><br><span class="line">&lt;&#x2F;activeProfiles&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>在IDEA中重新导入依赖</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405142135.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<h3 id="将个人到Maven项目发布到Nexus管理"><a href="#将个人到Maven项目发布到Nexus管理" class="headerlink" title="将个人到Maven项目发布到Nexus管理"></a>将个人到Maven项目发布到Nexus管理</h3><p>本节介绍如何把自己的项目发布到nexus ，这里单独开了一个仓库进行配置</p>
<p>在进行本节内容之前，查看Maven 到 <code>setting.xml</code>内容</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">&lt;!-- 用于发布正式版本 --&gt;</span><br><span class="line">&lt;server&gt;</span><br><span class="line">    &lt;id&gt;public&lt;&#x2F;id&gt;</span><br><span class="line">    &lt;username&gt;admin&lt;&#x2F;username&gt;</span><br><span class="line">    &lt;password&gt;admin123&lt;&#x2F;password&gt;	</span><br><span class="line">&lt;&#x2F;server&gt;</span><br><span class="line">&lt;!-- 测试 --&gt;</span><br><span class="line">&lt;server&gt;</span><br><span class="line">    &lt;id&gt;lazytime&lt;&#x2F;id&gt;</span><br><span class="line">    &lt;username&gt;admin&lt;&#x2F;username&gt;</span><br><span class="line">    &lt;password&gt;admin123&lt;&#x2F;password&gt;	</span><br><span class="line">&lt;&#x2F;server&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>在需要发布源代码到mavne项目<code>pom.xml</code>添加如下内容</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br></pre></td><td class="code"><pre><span class="line">&lt;build&gt;</span><br><span class="line">       &lt;pluginManagement&gt;&lt;!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --&gt;</span><br><span class="line">           &lt;plugins&gt;</span><br><span class="line">               &lt;!-- clean lifecycle, see https:&#x2F;&#x2F;maven.apache.org&#x2F;ref&#x2F;current&#x2F;maven-core&#x2F;lifecycles.html#clean_Lifecycle --&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-clean-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;3.1.0&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;!-- default lifecycle, jar packaging: see https:&#x2F;&#x2F;maven.apache.org&#x2F;ref&#x2F;current&#x2F;maven-core&#x2F;default-bindings.html#Plugin_bindings_for_jar_packaging --&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-resources-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;3.0.2&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-compiler-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;3.8.0&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-surefire-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;2.22.1&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-jar-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;3.0.2&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-install-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;2.5.2&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-deploy-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;2.8.2&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line">               &lt;!-- site lifecycle, see https:&#x2F;&#x2F;maven.apache.org&#x2F;ref&#x2F;current&#x2F;maven-core&#x2F;lifecycles.html#site_Lifecycle --&gt;</span><br><span class="line">               &lt;plugin&gt;</span><br><span class="line">                   &lt;artifactId&gt;maven-site-plugin&lt;&#x2F;artifactId&gt;</span><br><span class="line">                   &lt;version&gt;3.7.1&lt;&#x2F;version&gt;</span><br><span class="line">               &lt;&#x2F;plugin&gt;</span><br><span class="line"></span><br><span class="line">           &lt;&#x2F;plugins&gt;</span><br><span class="line">       &lt;&#x2F;pluginManagement&gt;</span><br><span class="line">   &lt;&#x2F;build&gt;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">   &lt;distributionManagement&gt;</span><br><span class="line">       &lt;repository&gt;</span><br><span class="line">           &lt;!-- 此id 必须对应setting 里面到 server id 否则会没有权限无法部署 --&gt;</span><br><span class="line">           &lt;id&gt;public&lt;&#x2F;id&gt;</span><br><span class="line">           &lt;url&gt;http:&#x2F;&#x2F;localhost:8081&#x2F;nexus&#x2F;content&#x2F;repositories&#x2F;lazytime&lt;&#x2F;url&gt;</span><br><span class="line">       &lt;&#x2F;repository&gt;</span><br><span class="line"></span><br><span class="line">   &lt;&#x2F;distributionManagement&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>以IDEA为例，<code>deloyer</code> 项目到 <code>maven Nexus</code></li>
</ol>
<p>运行<code>Maven Deloy</code>发布项目到nexus</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405162751.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>查看<code>Maven Nexus</code> ，查看发布的项目内容</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405162923.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<blockquote>
<p>如果不能发布，请查看仓库是否允许重新部署:</p>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405164619.png?ynotemdtimestamp=1595729096959" alt="img"></p>
</blockquote>
<h3 id="使用Snapshots-快照快捷管理项目迭代"><a href="#使用Snapshots-快照快捷管理项目迭代" class="headerlink" title="使用Snapshots 快照快捷管理项目迭代"></a>使用Snapshots 快照快捷管理项目迭代</h3><p>使用上一节办法存在很大到缺点：</p>
<ol>
<li>每次改动源代码就需要发布一个新版本，使用者就需要更新pom文件到项目版本号，或者本地仓库删掉旧依赖，重新引入依赖，这样非常麻烦</li>
<li>每次更新项目都需要通知使用者更新版本号</li>
</ol>
<p>如何解决如上问题呢？</p>
<p>那么我们就需要使用<code>快照</code>，快照相当于项目到一个副本，我们可以在开发到时候使用快照，发布到时候在使用正式到版本号进行处理，使nexus的管理更加方便</p>
<ol>
<li>打开maven nexus 主页，登陆管理员账户，查看如下内容</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405164857.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>在<code>Maven</code> 的<code>setting</code>文件当中添加如下内容，加入到对应的账号</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;server&gt;</span><br><span class="line">		&lt;id&gt;snapshots&lt;&#x2F;id&gt;</span><br><span class="line">		&lt;username&gt;admin&lt;&#x2F;username&gt;</span><br><span class="line">		&lt;password&gt;admin123&lt;&#x2F;password&gt;	</span><br><span class="line">	&lt;&#x2F;server&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>修改项目版本号，一定要依照maven到 <code>snaphoto</code> 规则，否则部署快照版本会失败</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;modelVersion&gt;4.0.0&lt;&#x2F;modelVersion&gt;</span><br><span class="line">&lt;groupId&gt;org.smart4j&lt;&#x2F;groupId&gt;</span><br><span class="line">&lt;artifactId&gt;smart-framwork&lt;&#x2F;artifactId&gt;</span><br><span class="line">&lt;!-- 写法一定要规范 --&gt;</span><br><span class="line">&lt;version&gt;1.0-SNAPSHOT&lt;&#x2F;version&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>执行<code>maven deloy</code> 部署配置</li>
</ol>
<p>注意待发布项目的<code>pom.xml</code>配置如下</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">&lt;distributionManagement&gt;</span><br><span class="line">        &lt;snapshotRepository&gt;</span><br><span class="line">            &lt;id&gt;snapshots&lt;&#x2F;id&gt;</span><br><span class="line">            &lt;url&gt;http:&#x2F;&#x2F;localhost:8081&#x2F;nexus&#x2F;content&#x2F;repositories&#x2F;snapshots&lt;&#x2F;url&gt;</span><br><span class="line">        &lt;&#x2F;snapshotRepository&gt;</span><br><span class="line">    &lt;&#x2F;distributionManagement&gt;</span><br></pre></td></tr></table></figure>

<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405170455.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>查看<code>Maven Nexus</code>是否发布成功</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405170339.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<blockquote>
<p>再次强调，如果部署失败，请查看仓库是否允许重复部署</p>
</blockquote>
<ol>
<li>接下来我们试下快照是如何解决版本迭代的问题的</li>
</ol>
<p>由于使用了快照版本，需要更改依赖如下:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;dependency&gt;</span><br><span class="line">    &lt;groupId&gt;org.smart4j&lt;&#x2F;groupId&gt;</span><br><span class="line">    &lt;artifactId&gt;smart-framwork&lt;&#x2F;artifactId&gt;</span><br><span class="line">    &lt;version&gt;1.0-SNAPSHOT&lt;&#x2F;version&gt;</span><br><span class="line">&lt;&#x2F;dependency&gt;</span><br></pre></td></tr></table></figure>

<ol>
<li>我们添加了一个main方法，然后点击IDEA <code>deploy</code>，部署快照版本的项目</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405201713.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<ol>
<li>我们在引用到项目里面可以看到项目已经引用到了本地当中</li>
</ol>
<p><img src="https://gitee.com/lazyTimes/imageReposity/raw/master/img/20200405202232.png?ynotemdtimestamp=1595729096959" alt="img"></p>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kity@2.0.4/dist/kity.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/kityminder-core@1.4.50/dist/kityminder.core.min.js"></script><script defer="true" type="text/javascript" src="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.js"></script><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/hexo-simple-mindmap@0.2.0/dist/mindmap.min.css">
    </div>

    
    
    
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>lazytime
  </li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="https://whitestore.top/2020/07/26/mavennexus/" title="【Maven】Maven私服Nexus搭建教程">https://whitestore.top/2020/07/26/mavennexus/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLzQuMC96aC1DTg=="><i class="fa fa-fw fa-creative-commons"></i>BY-NC</span> 许可协议。转载请注明出处！
  </li>
</ul>
</div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Maven/" rel="tag"># Maven</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item"></div>
      <div class="post-nav-item">
    <a href="/2020/07/26/picgomayun/" rel="next" title="PicGo和码云实现自建图床">
      PicGo和码云实现自建图床 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Nexus-私服搭建基本流程"><span class="nav-number">1.</span> <span class="nav-text">Nexus 私服搭建基本流程</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Nexus-是什么？"><span class="nav-number">1.1.</span> <span class="nav-text">Nexus 是什么？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#什么是Nexus-私服？"><span class="nav-number">1.2.</span> <span class="nav-text">什么是Nexus 私服？</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#maven的依赖管理"><span class="nav-number">1.3.</span> <span class="nav-text">maven的依赖管理</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#如何解决jar包冲突"><span class="nav-number">1.4.</span> <span class="nav-text">如何解决jar包冲突</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Nexus私服的秘密花园"><span class="nav-number">1.5.</span> <span class="nav-text">Nexus私服的秘密花园</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Nexus-下载地址"><span class="nav-number">1.6.</span> <span class="nav-text">Nexus 下载地址</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#快速入门"><span class="nav-number">1.7.</span> <span class="nav-text">快速入门</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#搭建Maven-Nexus"><span class="nav-number">1.7.1.</span> <span class="nav-text">搭建Maven Nexus</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#建立第一个个人仓库"><span class="nav-number">1.7.2.</span> <span class="nav-text">建立第一个个人仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将Jar包项目加入到个人仓库"><span class="nav-number">1.7.3.</span> <span class="nav-text">将Jar包项目加入到个人仓库</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将个人仓库的jar包添加到项目当中"><span class="nav-number">1.7.4.</span> <span class="nav-text">将个人仓库的jar包添加到项目当中</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#将个人到Maven项目发布到Nexus管理"><span class="nav-number">1.7.5.</span> <span class="nav-text">将个人到Maven项目发布到Nexus管理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#使用Snapshots-快照快捷管理项目迭代"><span class="nav-number">1.7.6.</span> <span class="nav-text">使用Snapshots 快照快捷管理项目迭代</span></a></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">阿东</p>
  <div class="site-description" itemprop="description">随遇而安</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">239</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">36</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">37</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2xhenlUaW1lcw==" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lazyTimes"><i class="fa fa-fw fa-github"></i>GitHub</span>
      </span>
      <span class="links-of-author-item">
        <span class="exturl" data-url="bWFpbHRvOjEwOTc0ODM1MDhAcXEuY29t" title="E-Mail → mailto:1097483508@qq.com"><i class="fa fa-fw fa-envelope"></i>E-Mail</span>
      </span>
  </div>


  <div class="links-of-blogroll motion-element">
    <div class="links-of-blogroll-title">
      <i class="fa fa-fw fa-link"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly93d3cuNTJwb2ppZS5jbi9ob21lLnBocD9tb2Q9c3BhY2UmdWlkPTE0OTc3MTgmZG89dGhyZWFkJnZpZXc9bWUmZnJvbT1zcGFjZQ==" title="https:&#x2F;&#x2F;www.52pojie.cn&#x2F;home.php?mod&#x3D;space&amp;uid&#x3D;1497718&amp;do&#x3D;thread&amp;view&#x3D;me&amp;from&#x3D;space">吾爱破解</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9qdWVqaW4uaW0vdXNlci8yOTk5MTIzNDUyNjI2MzY2" title="https:&#x2F;&#x2F;juejin.im&#x2F;user&#x2F;2999123452626366">掘金</span>
        </li>
        <li class="links-of-blogroll-item">
          <span class="exturl" data-url="aHR0cHM6Ly9zZWdtZW50ZmF1bHQuY29tL3UvbGF6eXRpbWVz" title="https:&#x2F;&#x2F;segmentfault.com&#x2F;u&#x2F;lazytimes">思否</span>
        </li>
    </ul>
  </div>

      </div>

      <div class="wechat_OA">
        <span>欢迎关注我的公众号</span>
        <br>
          <!-- 这里添加你的二维码图片 -->
        <img src ="https://adong-picture.oss-cn-shenzhen.aliyuncs.com/adong/wechat_channel.jpg">
      </div>
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          <span>0%</span>
        </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">阿东</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    <span title="站点总字数">2m</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">29:50</span>
</div>
  <div class="powered-by">由 <span class="exturl theme-link" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & <span class="exturl theme-link" data-url="aHR0cHM6Ly90aGVtZS1uZXh0Lm9yZw==">NexT.Gemini</span> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="//cdn.jsdelivr.net/gh/fancyapps/fancybox@3/dist/jquery.fancybox.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  




  
<script src="/js/local-search.js"></script>













  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : true,
      appId      : 'qMUpEEvBgXaMDD1b0ftgi9xr-gzGzoHsz',
      appKey     : 'UCdfT4Rfih6MO6y8DI4fstf6',
      placeholder: "Just go go",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : false,
      lang       : 'zh-CN' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
